package com.ryskoo.catering.producttemplateattrvalue.repository;

import com.ryskoo.catering.constant.HCLCacheConstant;
import com.ryskoo.catering.producttemplateattrvalue.domain.ProductTemplateAttrValuePO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

@Primary
@Repository
public class ProductTemplateAttrValueRedisImpl extends BasicRedisImpl<ProductTemplateAttrValuePO> implements IProductTemplateAttrValueRepository{

    @Autowired
    private RedisUtil redisClient;

    @Autowired
    private IProductTemplateAttrValueRepository productTemplateAttrValueRepository;

    @PostConstruct
    public void init(){
        this.setDao(productTemplateAttrValueRepository);
        this.setRedisClient(redisClient);
    }

    public ProductTemplateAttrValueRedisImpl() {
        super(HCLCacheConstant.HCL_PRODUCTTAG_KEY);
    }

    @Override
    public void deleteByAttrId(String attrId) {
        productTemplateAttrValueRepository.deleteByAttrId(attrId);
    }

    @Override
    public void deleteByAttrUuids(List<String> idList) {
        productTemplateAttrValueRepository.deleteByAttrUuids(idList);
    }

    @Override
    public List<ProductTemplateAttrValuePO> getByAttrUuid(String attrUuid) {
        return productTemplateAttrValueRepository.getByAttrUuid(attrUuid);
    }
}
